package edu.java.homework.hw03.ipj07;

import java.util.Arrays;
import java.util.Scanner;

public class Exer02 {

    public static void main(String[] args) {
	String[] stringArray = null;
	int dimention = 0;
	Scanner input = new Scanner(System.in);
	System.out.print("Pleae, enter the numbers of strings: ");
	dimention = input.nextInt();
	stringArray = new String[dimention];

	//input the array of strings
	inputArrayOfStrings(stringArray);
	//print the array of strings
	System.out.println(Arrays.toString(stringArray));
	
	String result = concatStrings(stringArray);
	System.out.println("\n\nResult: " + result);

	input.close();
    }

    public static String concatStrings(String[] strArr) {
	if (strArr== null) {
	    throw new IllegalArgumentException(
		    "Incorrect input; null-pointed array of srings");
	}
	
	StringBuffer sb=new StringBuffer();
	for(int i=0;i<strArr.length;i++){
	    sb.append(strArr[i]);
	}
	return sb.toString();
    }
    
    public static void inputArrayOfStrings(String[] strArr){
	if (strArr== null) {
	    throw new IllegalArgumentException(
		    "Incorrect input; null-pointed array of srings");
	}
	Scanner input= new Scanner(System.in);
	for(int i=0;i<strArr.length;i++){
	    System.out.print("string["+ i + "]= ");
	    strArr[i]=input.nextLine();
	}
	input.close();
    }

}
